/*
剑指 Offer II 105. 岛屿的最大面积
*/
#include <bits/stdc++.h>
using namespace std;
class Solution
{
public:
	int maxArea = 0;
	int dfs(vector<vector<int>> &grid, int i, int j)
	{
		if (i >= 0 && i < grid.size() && j >= 0 && j < grid[0].size() && grid[i][j] == 1)
		{
			grid[i][j] = 0;
			return 1 + dfs(grid, i + 1, j) + dfs(grid, i - 1, j) + dfs(grid, i, j - 1) + dfs(grid, i, j + 1);
		}
		return 0;
	}
	int maxAreaOfIsland(vector<vector<int>> &grid)
	{
		for (int i = 0; i < grid.size(); i++)
		{
			for (int j = 0; j < grid[0].size(); j++)
			{
				if (grid[i][j] == 1)
					maxArea = max(maxArea, dfs(grid, i, j));
			}
		}
		return maxArea;
	}
};
int main()
{

	return 0;
}
